package com.x.crm.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.crm.dao.FollowDao;
import com.x.crm.manage.FollowManage;
import com.x.crm.model.Follow;
import com.x.crm.rpc.FollowRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Service(interfaceName = "com.x.crm.rpc.FollowRpcService", timeout = 60000)
public class FollowService extends BaseService implements FollowRpcService {
    @Autowired
    private FollowDao followDao;

    @Autowired
    private FollowManage followManage;

    public List<Follow> selectFollowList(Follow follow) {
        try{
            return followDao.selectFollowList(follow);
        }catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0008, e);
        }
    }
    public Follow insertFollow(Follow follow){
        try {
            return followManage.insertFollow(follow);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0009, e);
        }
    }

    public int updateFollow(Follow followSet, Follow followWhere) {
        try {
            return followDao.update(followSet, followWhere);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0010, e);
        }
    }
}
